package com.compus_help.controller.admin;

import com.compus_help.common.PageResult;
import com.compus_help.common.Result;
import com.compus_help.entity.DTO.OrderPageDTO;
import com.compus_help.service.adminOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@RestController
@RequestMapping("/admin")
public class adminOrderController {
    private static final Logger log = LoggerFactory.getLogger(adminOrderController.class);
    @Autowired
    private adminOrderService adminOrderService;

    // 订单分页查询
    @GetMapping("/orders/page")
    public Result<PageResult> getOrderPage(OrderPageDTO orderPageDTO) {
        PageResult pageResult;
        try {
            pageResult = adminOrderService.getOrderPage(orderPageDTO);
        } catch (Exception e) {
            log.error("分页查询订单失败", e);
            return Result.error(e.getMessage());
        }
        log.info("分页查询订单成功");
        return Result.success(pageResult);
    }


}
